package com.yswee.framework.utils;

import com.yswee.framework.R;
import com.yswee.framework.widget.dialog.MDialog;
import com.yswee.framework.widget.dialog.MDialog.AlertDlgBuilder;

import android.content.Context;
import android.view.Gravity;
import android.view.View;


public class DialogUtils {
	
	public static MDialog showConfirmDialog(Context context, int messageResId, View.OnClickListener onclicklistener) {
		return showConfirmDialog(context, context.getResources().getString(R.string.dialog_alert), 
				context.getResources().getString(messageResId), onclicklistener);
	}
	
	public static MDialog showConfirmDialog(Context context, CharSequence message, View.OnClickListener onclicklistener) {
		return showConfirmDialog(context, context.getResources().getString(R.string.dialog_alert), message, onclicklistener);
	}
	
	public static MDialog showConfirmDialog(Context context, CharSequence message, 
			View.OnClickListener okclicklistener, View.OnClickListener cancelclicklistener) {
		return showConfirmDialog(context, context.getResources().getString(R.string.dialog_alert), message,
				okclicklistener, cancelclicklistener);
	}
	
	public static MDialog showConfirmDialog(Context context, CharSequence title, CharSequence message, View.OnClickListener onclicklistener) {
		return showConfirmDialog(context, title, message, onclicklistener, null);
	}
	
	public static MDialog showConfirmDialog(Context context, CharSequence title, CharSequence message, 
			View.OnClickListener okclicklistener, View.OnClickListener cancelclicklistener) {
		return showConfirmDialog(context, 0, title, message, 
				context.getResources().getString(R.string.dialog_ok),
				context.getResources().getString(R.string.dialog_cancel), 
				okclicklistener, cancelclicklistener);
	}

	public static MDialog showConfirmDialog(Context context, int iconId, CharSequence title, CharSequence msg, String ok, 
			String cancel, View.OnClickListener okclicklistener) {
		return showConfirmDialog(context, iconId, title, msg, ok, cancel, okclicklistener, null);
	}

	public static MDialog showConfirmDialog(Context context, int iconId, CharSequence title, CharSequence msg, String ok, 
			String cancel, View.OnClickListener okclicklistener, View.OnClickListener cancelclicklistener) {
		MDialog.AlertDlgBuilder build = new AlertDlgBuilder(context);
		MDialog dialog = build.setLayoutView(R.layout.widget_mdialog).
				setGravity(Gravity.CENTER_VERTICAL).
				setIcon(iconId).setTitle(title).setMessage(msg).
				setPositiveButton(ok, okclicklistener).
				setNegativeButton(cancel, cancelclicklistener).create();
		dialog.show();
		return dialog;
	}

}
